package cst.a110lyj.fragmenttest110lyj.fragment;


import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import java.util.List;

import cst.a110lyj.fragmenttest110lyj.R;
import cst.a110lyj.fragmenttest110lyj.adapter.MyAdapter;
import cst.a110lyj.fragmenttest110lyj.bean.ArticleBean;
import cst.a110lyj.fragmenttest110lyj.iface.AmicoolListener;
import cst.a110lyj.fragmenttest110lyj.model.AmicoolModel;

/**
 * A simple {@link Fragment} subclass.
 */
public class VideoFragmentSecond_2 extends Fragment {
    private View view;
    private Context context;
    private  String mod;
    private TextView tvinfo;
    private RecyclerView recyclerView;
    private RecyclerView.LayoutManager layoutManager;
    private MyAdapter mAdapter;
    List<ArticleBean> list = null;
    AmicoolListener<List<ArticleBean>> Listener = new AmicoolListener<List<ArticleBean>>() {
        @Override
        public void onResponse(List<ArticleBean> l) {
            mAdapter.setList(l);
            Toast.makeText(context, "ertert", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onFail(String msg) {
            Toast.makeText(context, "e4444t", Toast.LENGTH_SHORT).show();
        }
    };

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        context = getActivity();
        view = inflater.inflate(R.layout.wfragment,container,false);
        recyclerView = (RecyclerView)view.findViewById(R.id.recyclerview);
        layoutManager = new LinearLayoutManager(context);
        recyclerView.setLayoutManager(layoutManager);
        mAdapter = new MyAdapter(context,"video");
        mAdapter.setList(list);
        recyclerView.setAdapter(mAdapter);
        SharedPreferences sp = context.getSharedPreferences("login",Context.MODE_PRIVATE);
        String id = sp.getString("sessionid",null );
        AmicoolModel amicoolModel =new AmicoolModel("gson");
        amicoolModel.getList("video2",1,id,Listener);
        return  view;
    }
}

